/**
 * Project Name:JZGPingGuShi
 * File Name:ActivityHelp.java
 * Package Name:com.gc.jzgpinggushi.app
 * Date:2014-9-1上午10:17:48
 * Copyright (c) 2014, wangyd523@gmail.com All Rights Reserved.
 */

package com.jzg.jcptadmin.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;

import com.jzg.jcptadmin.constant.Constant;
import com.jzg.jcptadmin.ui.InPutCarNumberActivity;
import com.jzg.jcptadmin.ui.RadioActivity1;

import java.io.Serializable;

/**
 * ClassName:ActivityHelp <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON. <br/>
 * Date: 2014-9-1 上午10:17:48 <br/>
 *
 * @author 汪渝栋
 * @see
 * @since JDK 1.6
 */
public class ActivityHelp {

    public static final String MAKELIST = "makelist";
    public static final String Make = "make";
    public static final String Model = "model";
    public static final String ESTIMATEDETAILS = "estimateDetails";
    public static final String VINDETAILS = "vinDetails";

    public static final String KEY_BRAND = "brand";
    public static final String KEY_SERIES = "series";
    public static final String KEY_MODEL = "model";
    public static final String KEY_MODEL_ID = "modelId";
    public static final String KEY_MAKE_ID = "makeId";

    public static final String KEY_IMG_URLS = "imgUrls";
    public static final String KEY_POSITION = "position";

    /**
     * 无参activity启动 startActivity: <br/>
     *
     * @param context
     * @param cls
     * @author wang
     * @since JDK 1.6
     */
    @SuppressWarnings("rawtypes")
    public static void startActivity(Context context, Class cls) {
        Intent intent = new Intent(context, cls);
        context.startActivity(intent);

    }

    /**
     * 有参activity启动， startActivity: <br/>
     *
     * @param context    当前context
     * @param cls        启动的activity
     * @param nameFlag   名称标记，启动activity获取对应数据使用
     * @param parcelable 参数实体
     * @author wang
     * @since JDK 1.6
     */
    public static void startActivity(Context context, Class cls,
                                     String nameFlag, Parcelable parcelable) {
        Intent intent = new Intent(context, cls);
        intent.putExtra(nameFlag, parcelable);
        context.startActivity(intent);
    }

    public static void startActivityForResult(Activity context, Class cls,
                                     String nameFlag, Serializable serializable,int requestCode) {
        Intent intent = new Intent(context, cls);
        intent.putExtra(nameFlag, serializable);
        intent.putExtra("requestCode", requestCode);
        context.startActivityForResult(intent, requestCode);
    }

    /**
     * 有参activity启动， startActivity: <br/>
     *
     * @param context  当前context
     * @param cls      启动的activity
     * @param nameFlag 名称标记，启动activity获取对应数据使用
     * @param b        是/否
     * @author wang
     * @since JDK 1.6
     */
    public static void startActivity(Context context, Class cls,
                                     String nameFlag, boolean b) {
        Intent intent = new Intent(context, cls);
        intent.putExtra(nameFlag, b);
        context.startActivity(intent);
    }


    /**
     * 有参activity启动， startActivity: <br/>
     *
     * @param context     当前context
     * @param cls         启动的activity
     * @param nameFlag1   名称标记，启动activity获取对应数据使用
     * @param parcelable1 参数实体
     * @author wang
     * @since JDK 1.6
     */
    public static void startActivity(Context context, Class cls,
                                     String nameFlag1, Parcelable parcelable1, String nameFlag2, Parcelable parcelable2) {
        Intent intent = new Intent(context, cls);
        intent.putExtra(nameFlag1, parcelable1);
        intent.putExtra(nameFlag2, parcelable2);
        context.startActivity(intent);
    }

    /**
     * 有参activity启动， startActivity: <br/>
     *
     * @param context    当前context
     * @param cls        启动的activity
     * @param nameFlag   名称标记，启动activity获取对应数据使用
     * @param parcelable 参数实体 @param intentflag intent标记
     * @author wang
     * @since JDK 1.6
     */
    public static void startActivity(Context context, Class cls,
                                     String nameFlag, Parcelable parcelable, int intentflag) {
        Intent intent = new Intent(context, cls);
        intent.putExtra(nameFlag, parcelable);
        intent.addFlags(intentflag);
        context.startActivity(intent);
    }

    /**
     * intent标记跳转
     *
     * @param context
     * @param cls
     * @param intentflag
     */
    public static void startActivity(Context context, Class cls, int intentflag) {
        Intent intent = new Intent(context, cls);
        intent.addFlags(intentflag);
        context.startActivity(intent);
    }

    /**
     * 传Bundle activity启动 startActivity: <br/>
     *
     * @param context
     * @param cls
     * @author wang
     * @since JDK 1.6
     */
    @SuppressWarnings("rawtypes")
    public static void startActivity(Context context, Class cls, Bundle bd) {
        Intent intent = new Intent(context, cls);
        intent.putExtras(bd);
        context.startActivity(intent);

    }

    /**
     * 跳转到单选界面
     * start_radioActivity
     * requestCode  返回code
     * title  标题
     * redios  展现单选选项
     */
    public static void start_radioActivity(Activity context, int requestCode, String title, String[] radios, int checkPos) {
        Intent intent = new Intent(context, RadioActivity1.class);
        intent.putExtra("requestCode", requestCode);
        intent.putExtra(Constant.activity_radio_title, title);
        intent.putExtra(Constant.activity_radioGroup, radios);
        intent.putExtra(Constant.activity_radio_pos, checkPos);
        context.startActivityForResult(intent, requestCode);
    }
    /**
     * 跳转到校验输入Activity
     * @param requestcode 请求码
     * @param title       标题
     * @param hint        提示文字
     * @param type        输入类型   -1默认，0代表VIN，1电话号,2代表可以输入小数,3代表email，4代表发动机：数字字母横线
     * @param length      输入长度
     * @param showText    上次输入的文字
     */
    public static void startCheckInputActivity(Activity context,int requestcode, String title, String hint, int type, int length, String showText) {
        Intent intent = new Intent(context, InPutCarNumberActivity.class);
        intent.putExtra(Constant.INPUT_REQUESTCODE, requestcode);
        intent.putExtra(Constant.INPUT_TITLE, title);
        intent.putExtra(Constant.INPUT_HINT, hint);
        intent.putExtra(Constant.INPUT_TYPE, type);
        intent.putExtra(Constant.INPUT_LENGTH, length);
        intent.putExtra(Constant.SHOWTEXT, showText);
        context.startActivityForResult(intent, requestcode);
    }
}
